package com.example.win.android_banduyujia.venuesactivity.activity.openactivity;

import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.peopleactivity.activity.activity.openactivity.courseactivity.adapter.TodayAdapter;
import com.example.win.android_banduyujia.peopleactivity.ui.activity.BaseTitleBarActivity;
import com.example.win.android_banduyujia.peopleactivity.ui.layout.RefreshLayout;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by Win on 2015/9/6.
 */
public class VenuesTodayActivity extends BaseTitleBarActivity implements SwipeRefreshLayout.OnRefreshListener, RefreshLayout.OnLoadListener {
    public static final String TAG=VenuesTodayActivity.class.getSimpleName();

    private RefreshLayout swipeLayout;
    private ArrayList<HashMap<String, String>>   list;
    private View header;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_today_page);

        InitTitles();
        InitViews();
        setListener();
    }

    private void InitTitles() {
        showLeftBackButton();
        setTitle(R.string.fragment_today_course_number);
    }

    private void InitViews() {
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_today_list_vertical);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        String[]  dataset = new String[3];
        for (int i=0;i>dataset.length;i++){
            dataset[3]="items"+i;
        }
        TodayAdapter adapter = new TodayAdapter(dataset);
        recyclerView.setAdapter(adapter);

        header = getLayoutInflater().inflate(R.layout.layout_refresh_header, null);
        swipeLayout=(RefreshLayout) findViewById(R.id.swipe_container);
        swipeLayout.setOnRefreshListener(this);
        swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);

        list = new ArrayList<HashMap<String, String>>();
        for(int i=0; i <10;i++){
            list.add(new HashMap<String, String>());
        }
    }

    private void setListener() {
        swipeLayout.setOnLoadListener(this);
        swipeLayout.setOnRefreshListener(this);
    }

    @Override
    public void onRefresh() {
        swipeLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
              swipeLayout.setRefreshing(false);
            }
        },1000);
    }

    @Override
    public void onLoad() {
        swipeLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                swipeLayout.setLoading(false);
            }
        },1000);
    }
}
